﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JqueryNet.FormControl.FormHtmlControl
{
    public class JHtmlTextArea : JHtmlControl
    {
        private System.Web.UI.HtmlControls.HtmlTextArea htmlTextArea;

        public JHtmlTextArea(System.Web.UI.HtmlControls.HtmlTextArea htmlTextArea)
            : base(htmlTextArea)
        {
            // TODO: Complete member initialization
            this.htmlTextArea = htmlTextArea;
        }

        public override void Attr(string key)
        {
            switch (key.ToLower())
            {
                case "cols":
                    Value = htmlTextArea.Cols;
                    return;
                case "rows":
                    Value = htmlTextArea.Rows;
                    return;
                default:
                    base.Attr(key);
                    return;
            }
        }

        public override void Attr(string key, string value)
        {
            int b;
            int.TryParse(value, out b);
            switch (key.ToLower())
            {
                case "cols":
                    htmlTextArea.Cols = b;
                    return;
                case "rows":
                    htmlTextArea.Rows = b;
                    return;
                default:
                    base.Attr(key, value);
                    return;
            }
        }

        public override void Val()
        {
            Value = htmlTextArea.Value;
        }

        public override void Val(string value)
        {
            htmlTextArea.Value = value;
        }

        public override void Html()
        {
            Value = htmlTextArea.InnerHtml;
        }

        public override void Html(Func<string> fun)
        {
            htmlTextArea.InnerHtml = fun();
        }

        public override void Html(string value)
        {
            htmlTextArea.InnerHtml = value;
        }

        public override void Text()
        {
            Value = htmlTextArea.InnerText;
        }

        public override void Text(Func<string> fun)
        {
            htmlTextArea.InnerText = fun();
        }

        public override void Text(string value)
        {
            htmlTextArea.InnerText = value;
        }

    }
}
